package api.ttInteraction;

import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;

import java.lang.ref.SoftReference;

/**
 * 头条模板插屏
 */
public abstract class Interaction_API_TT {

    public static String clazz = "com.dotools.toutiaolibrary.TT_ExpressInteraction";

    private static SoftReference<Interaction_API_TT> sf;

    public synchronized static Interaction_API_TT getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((Interaction_API_TT) o);
                return (Interaction_API_TT) o;
            }
        }
        return sf == null ? null : sf.get();
    }

    /**
     * @param activity      Activity
     * @param appid        程序id
     * @param adposid      广告id
     * @param listener
     */
    public abstract void LoadTTInteraction(Activity activity, String appid, String adposid, int expressViewWidth, int expressViewHeight, int downloadMode, final TTInteractionListener listener);


    public abstract void  onDestroy();

    public interface TTInteractionListener {
        void onLoad();
        void onObClicked(int type);
        void onObShow(int type);
        void onRenderFail(String msg, int code);
        void onRenderSuccess();
        void onError(int code, String message);
    }
}